package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.sky.dto.EmployeeDTO;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface EmployeeMapper {
    //查询重复
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);
    //插入
    @Insert("insert into employee" +
            " (name, username, password, phone, sex, id_number, create_time, update_time, create_user, update_user,status)" +
            "values" + "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    void insert(Employee employee);
    //分页
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);
    //更新状态
    @Update("update employee set status=#{status} where id=#{id}")
    void reviseStatus(Integer status, Integer id);
    //根据id查
    @Select("select * from employee where id=#{id}")
    Employee findEmployeeById(Integer id);
    //更新用户
    @Update("update employee set name=#{name},username=#{username},phone=#{phone},sex=#{sex},id_number=#{idNumber} where id=#{id}")
    void reviseInfo(Employee employee);
}
